package cqrtplm.controller;

import com.hustcad.plm.pdm.file.handler.response.ResponseResult;
import cqrtplm.constant.RouteConstant;
import cqrtplm.dto.RtCfgTemplatecontentConstraintsDTO;
import cqrtplm.entity.RtCfgTemplatecontentConstraintsDO;
import cqrtplm.service.RtCfgTemplatecontentConstraintsService;
import cqrtplm.vo.ModelAndProductTypeVO;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.Map;

@RestController
@Api(tags = "需求管理-选项规则约束")
@RequestMapping(RouteConstant.RTCFGTEMPLATECONTENTCONSTRAINTS + "v1")
public class RtCfgTemplatecontentConstraintsController {
    @Resource
    private RtCfgTemplatecontentConstraintsService rtCfgTemplatecontentConstraintsService;

    //保存选项规则约束
    @PostMapping("/saveRtCfgTemplatecontentConstraints")
    public ResponseResult saveRtCfgTemplatecontentConstraints(@RequestBody RtCfgTemplatecontentConstraintsDO rtCfgTemplatecontentConstraintsDO) {
        return rtCfgTemplatecontentConstraintsService.saveRtCfgTemplatecontentConstraints(rtCfgTemplatecontentConstraintsDO);
    }
    //测试
    @PostMapping("/testRtCfgTemplatecontentConstraints")
    public ResponseResult testRtCfgTemplatecontentConstraints(@RequestBody Map<String,String> map)  {
        return rtCfgTemplatecontentConstraintsService.testRtCfgTemplatecontentConstraints(map);
    }
    //获取规则内容树状结构
    @PostMapping("/getRtCfgStatusSubTree")
    public ResponseResult getRtCfgStatusSubTree(@RequestBody ModelAndProductTypeVO modelAndProductTypeVO)
            throws ParseException {
        return rtCfgTemplatecontentConstraintsService.getRtCfgStatusSubTree(modelAndProductTypeVO);
    }
    //删除选项规则约束
    @DeleteMapping("/removeRtCfgTemplatecontentConstraints")
    public ResponseResult removeRtCfgTemplatecontentConstraints(@RequestBody BigInteger[] ids) {
        return rtCfgTemplatecontentConstraintsService.removeRtCfgTemplatecontentConstraints(ids);
    }
    //获取选项规则约束列表
    @PostMapping("/getRtCfgTemplatecontentConstraints")
    public ResponseResult getRtCfgTemplatecontentConstraints(@RequestBody RtCfgTemplatecontentConstraintsDTO rtCfgTemplatecontentConstraintsDTO) {
        return rtCfgTemplatecontentConstraintsService.getRtCfgTemplatecontentConstraints(rtCfgTemplatecontentConstraintsDTO);
    }
    //修改选项规则约束
    @PutMapping( "/updateRtCfgTemplatecontentConstraints")
    public ResponseResult updateRtCfgTemplatecontentConstraints(@RequestBody RtCfgTemplatecontentConstraintsDO rtCfgTemplatecontentConstraintsDO) {
        return rtCfgTemplatecontentConstraintsService.updateRtCfgTemplatecontentConstraints(rtCfgTemplatecontentConstraintsDO);
    }
}
